Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
The merge-refs npm package is a utility for combining multiple React refs into a single ref. This is particularly useful when you need to pass multiple refs to a single component or element.
Combining Multiple Refs
This feature allows you to combine multiple refs into a single ref. In this example, `ref1` and `ref2` are combined and passed to a `div` element.
import React, { useRef } from 'react';
import mergeRefs from 'merge-refs';
const MyComponent = () => {
const ref1 = useRef();
const ref2 = useRef();
return <div ref={mergeRefs([ref1, ref2])}>Hello World</div>;
};
The react-merge-refs package provides similar functionality by allowing you to merge multiple refs into one. It is very similar to merge-refs in terms of usage and purpose.
A function that merges React refs into one. Filters out invalid (eg. falsy) refs as well and returns original ref if only one valid ref was given.
npm install merge-refs
or yarn add merge-refs
.import mergeRefs from 'merge-refs'
.ref
like so: <div ref={mergeRefs(ref, someOtherRef)} />
createRef()
useRef()
function Hello() {
const ref1 = useRef<HTMLDivElement>(); // I'm going to be updated!
const ref2 = (element: HTMLDivElement) => {
// I'm going to be called!
};
return <div ref={mergeRefs(ref1, ref2)} />;
}
The MIT License.
Wojciech Maj |
FAQs
A function that merges React refs into one.
The npm package merge-refs receives a total of 648,099 weekly downloads. As such, merge-refs popularity was classified as popular.
We found that merge-refs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.